#ifndef RTSP_CLIENT_H
#define RTSP_CLIENT_H

#include <iostream>
#include <istream>
#include <ostream>
#include <string>
#include <memory>
#include <asio.hpp>

#include "RtspMethod.h"

using asio::ip::tcp;

namespace rtsp{

class RtspClient : public std::enable_shared_from_this<RtspClient>
{
public:
    RtspClient(const std::string& url, asio::io_context& ioContext);
    //RtspClient(const std::string& address, const std::string& port, const std::string& absPath);
    ~RtspClient();

    void start();

private:
    void onOption();
    void onDescribe();
    void readStatusLine();
    void onStatusLine();
    void readHeaders();
    void readSdp();
    void onSdp();

private:
    asio::io_context& ioContext_;
    tcp::resolver resolver_;
    tcp::socket socket_;
    asio::streambuf request_;
    asio::streambuf response_;

    std::string absUrl_;
    std::string address_;
    std::string port_;
    std::string absPath_;
    std::string userName_;
    std::string passWord_;

    int seq_{1};
    Method method_{Method::kUnknown};
};

}

#endif
